//
//  CategoryNaviView.m
//  BaseProject
//
//  Created by 王洋 on 2020/7/20.
//  Copyright © 2020 王洋. All rights reserved.
//

#import "CategoryNaviView.h"

@implementation CategoryNaviView

- (void)awakeFromNib {
    [super awakeFromNib];
    
    UIImageView *imgv = [[UIImageView alloc] initWithFrame:CGRectMake(12, 12, 16, 16)];
    [imgv setImage:[UIImage imageNamed:@"common_search"]];
    
    UIView *leftView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 40, 40)];
    leftView.backgroundColor = [UIColor clearColor];
    [leftView addSubview:imgv];
    
    self.searchTF.leftView =leftView;
    self.searchTF.leftViewMode = UITextFieldViewModeAlways;
}

- (IBAction)imAction:(id)sender {
    if (self.CategoryNaviViewBlock) {
        self.CategoryNaviViewBlock(CategoryNaviViewType_im);
    }
}

- (IBAction)cartAction:(id)sender {
    if (self.CategoryNaviViewBlock) {
        self.CategoryNaviViewBlock(CategoryNaviViewType_cart);
    }
}

- (void)layoutSubviews {
    [super layoutSubviews];
    
    dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.01 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
        [self.searchTF pp_clipCorners:UIRectCornerAllCorners radius:self.searchTF.frame.size.height/2 border:1 color:UIColorHex(0xf1f1f1)];
    });
    
}



@end
